using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class OrderInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			UserID,
			Bill_Name,
			Bill_Address,
			Bill_Phone,
			Ship_Name,
			Ship_Address,
			Ship_Phone,
			IDStatus,
			DateTime,
			OrderProducts,
			IDPayment,
			Bill_City,
			Bill_Country,
			Ship_City,
			Ship_Country,
			Notes
		}
		private Int32 _ID;
		private Int32 _UserID;
		private String _Bill_Name;
		private String _Bill_Address;
		private String _Bill_Phone;
		private String _Ship_Name;
		private String _Ship_Address;
		private String _Ship_Phone;
		private Int32 _IDStatus;
		private DateTime _DateTime;
		private String _OrderProducts;
		private Int32 _IDPayment;
		private String _Bill_City;
		private String _Bill_Country;
		private String _Ship_City;
		private String _Ship_Country;
		private String _Notes;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public Int32 UserID{	get{ return _UserID;} set{_UserID = value;} }
		public String Bill_Name{	get{ return _Bill_Name;} set{_Bill_Name = value;} }
		public String Bill_Address{	get{ return _Bill_Address;} set{_Bill_Address = value;} }
		public String Bill_Phone{	get{ return _Bill_Phone;} set{_Bill_Phone = value;} }
		public String Ship_Name{	get{ return _Ship_Name;} set{_Ship_Name = value;} }
		public String Ship_Address{	get{ return _Ship_Address;} set{_Ship_Address = value;} }
		public String Ship_Phone{	get{ return _Ship_Phone;} set{_Ship_Phone = value;} }
		public Int32 IDStatus{	get{ return _IDStatus;} set{_IDStatus = value;} }
		public DateTime DateTime{	get{ return _DateTime;} set{_DateTime = value;} }
		public String OrderProducts{	get{ return _OrderProducts;} set{_OrderProducts = value;} }
		public Int32 IDPayment{	get{ return _IDPayment;} set{_IDPayment = value;} }
		public String Bill_City{	get{ return _Bill_City;} set{_Bill_City = value;} }
		public String Bill_Country{	get{ return _Bill_Country;} set{_Bill_Country = value;} }
		public String Ship_City{	get{ return _Ship_City;} set{_Ship_City = value;} }
		public String Ship_Country{	get{ return _Ship_Country;} set{_Ship_Country = value;} }
		public String Notes{	get{ return _Notes;} set{_Notes = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public OrderInfo()
		{
			_ID = 0;
			_UserID = 0;
			_Bill_Name = "";
			_Bill_Address = "";
			_Bill_Phone = "";
			_Ship_Name = "";
			_Ship_Address = "";
			_Ship_Phone = "";
			_IDStatus = 0;
			_DateTime = DateTime.Now;
			_OrderProducts = "";
			_IDPayment = 0;
			_Bill_City = "";
			_Bill_Country = "";
			_Ship_City = "";
			_Ship_Country = "";
			_Notes = "";
		}
		public OrderInfo(
		Int32 ID,
		Int32 UserID,
		String Bill_Name,
		String Bill_Address,
		String Bill_Phone,
		String Ship_Name,
		String Ship_Address,
		String Ship_Phone,
		Int32 IDStatus,
		DateTime DateTime,
		String OrderProducts,
		Int32 IDPayment,
		String Bill_City,
		String Bill_Country,
		String Ship_City,
		String Ship_Country,
		String Notes
		)
		{
			_ID = ID;
			_UserID = UserID;
			_Bill_Name = Bill_Name;
			_Bill_Address = Bill_Address;
			_Bill_Phone = Bill_Phone;
			_Ship_Name = Ship_Name;
			_Ship_Address = Ship_Address;
			_Ship_Phone = Ship_Phone;
			_IDStatus = IDStatus;
			_DateTime = DateTime;
			_OrderProducts = OrderProducts;
			_IDPayment = IDPayment;
			_Bill_City = Bill_City;
			_Bill_Country = Bill_Country;
			_Ship_City = Ship_City;
			_Ship_Country = Ship_Country;
			_Notes = Notes;
		}
		public OrderInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_UserID = dr[Field.UserID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.UserID.ToString()]);
				_Bill_Name = dr[Field.Bill_Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Bill_Name.ToString()]);
				_Bill_Address = dr[Field.Bill_Address.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Bill_Address.ToString()]);
				_Bill_Phone = dr[Field.Bill_Phone.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Bill_Phone.ToString()]);
				_Ship_Name = dr[Field.Ship_Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ship_Name.ToString()]);
				_Ship_Address = dr[Field.Ship_Address.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ship_Address.ToString()]);
				_Ship_Phone = dr[Field.Ship_Phone.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ship_Phone.ToString()]);
				_IDStatus = dr[Field.IDStatus.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDStatus.ToString()]);
				_DateTime = dr[Field.DateTime.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.DateTime.ToString()]);
				_OrderProducts = dr[Field.OrderProducts.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.OrderProducts.ToString()]);
				_IDPayment = dr[Field.IDPayment.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.IDPayment.ToString()]);
				_Bill_City = dr[Field.Bill_City.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Bill_City.ToString()]);
				_Bill_Country = dr[Field.Bill_Country.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Bill_Country.ToString()]);
				_Ship_City = dr[Field.Ship_City.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ship_City.ToString()]);
				_Ship_Country = dr[Field.Ship_Country.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Ship_Country.ToString()]);
				_Notes = dr[Field.Notes.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Notes.ToString()]);
			}
		}
		public OrderInfo(OrderInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_UserID = objEntr.UserID;			
			_Bill_Name = objEntr.Bill_Name;			
			_Bill_Address = objEntr.Bill_Address;			
			_Bill_Phone = objEntr.Bill_Phone;			
			_Ship_Name = objEntr.Ship_Name;			
			_Ship_Address = objEntr.Ship_Address;			
			_Ship_Phone = objEntr.Ship_Phone;			
			_IDStatus = objEntr.IDStatus;			
			_DateTime = objEntr.DateTime;			
			_OrderProducts = objEntr.OrderProducts;			
			_IDPayment = objEntr.IDPayment;			
			_Bill_City = objEntr.Bill_City;			
			_Bill_Country = objEntr.Bill_Country;			
			_Ship_City = objEntr.Ship_City;			
			_Ship_Country = objEntr.Ship_Country;			
			_Notes = objEntr.Notes;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Order");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.UserID.ToString(), typeof(Int32)),
				new DataColumn(Field.Bill_Name.ToString(), typeof(String)),
				new DataColumn(Field.Bill_Address.ToString(), typeof(String)),
				new DataColumn(Field.Bill_Phone.ToString(), typeof(String)),
				new DataColumn(Field.Ship_Name.ToString(), typeof(String)),
				new DataColumn(Field.Ship_Address.ToString(), typeof(String)),
				new DataColumn(Field.Ship_Phone.ToString(), typeof(String)),
				new DataColumn(Field.IDStatus.ToString(), typeof(Int32)),
				new DataColumn(Field.DateTime.ToString(), typeof(DateTime)),
				new DataColumn(Field.OrderProducts.ToString(), typeof(String)),
				new DataColumn(Field.IDPayment.ToString(), typeof(Int32)),
				new DataColumn(Field.Bill_City.ToString(), typeof(String)),
				new DataColumn(Field.Bill_Country.ToString(), typeof(String)),
				new DataColumn(Field.Ship_City.ToString(), typeof(String)),
				new DataColumn(Field.Ship_Country.ToString(), typeof(String)),
				new DataColumn(Field.Notes.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.UserID.ToString()] = _UserID;
			row[Field.Bill_Name.ToString()] = _Bill_Name;
			row[Field.Bill_Address.ToString()] = _Bill_Address;
			row[Field.Bill_Phone.ToString()] = _Bill_Phone;
			row[Field.Ship_Name.ToString()] = _Ship_Name;
			row[Field.Ship_Address.ToString()] = _Ship_Address;
			row[Field.Ship_Phone.ToString()] = _Ship_Phone;
			row[Field.IDStatus.ToString()] = _IDStatus;
			row[Field.DateTime.ToString()] = _DateTime;
			row[Field.OrderProducts.ToString()] = _OrderProducts;
			row[Field.IDPayment.ToString()] = _IDPayment;
			row[Field.Bill_City.ToString()] = _Bill_City;
			row[Field.Bill_Country.ToString()] = _Bill_Country;
			row[Field.Ship_City.ToString()] = _Ship_City;
			row[Field.Ship_Country.ToString()] = _Ship_Country;
			row[Field.Notes.ToString()] = _Notes;
			return row;
		}
        #endregion InitTable
    }
}
